﻿/*----------------------------------------------------------------
// Copyright (C) 2016 通通优品版权所有。
// 命名空间: STOWaybillMall.Dapper
// 类名：STOWaybillMallDataModule
// 功能描述：N/A
// 
// 创建标识：Roc.Lee(李鹏鹏) 2017/8/9 16:02:27 TEC-ROCLEE Roc.Lee

// 修改标识：
// 修改描述：
// 
//
//----------------------------------------------------------------*/
using Abp.Dapper;
using Abp.Modules;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using DapperExtensions;
using Abp.Domain.Uow;
using Castle.MicroKernel.Registration;
using Abp.MultiTenancy;

namespace STOWaybillMall.Dapper
{
    [DependsOn(typeof(AbpDapperModule), typeof(STOWaybillMallCoreModule))]
    public class STOWaybillMallDataModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.ReplaceService(typeof(IConnectionStringResolver), () =>
            {
                IocManager.IocContainer.Register(
                    Component.For<IConnectionStringResolver, IDbPerTenantConnectionStringResolver>()
                        .ImplementedBy<DbPerTenantConnectionStringResolver>()
                        .LifestyleTransient()
                    );
            });
            Configuration.DefaultNameOrConnectionString = "STO_Waybill_Mall";
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            DapperExtensions.DapperExtensions.SetMappingAssemblies(new List<Assembly> { Assembly.GetExecutingAssembly() });
        }
    }
}
